﻿<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
                assembly="KuaJing.Orders"
				        namespace="KuaJing.Orders.Domain">

  <class name="Order" table="Orders_Order">
    <id name="Id" access="field.camelcase" type="Int32" column="OrderId">
      <generator class="native" />
    </id>
    <version name="Version" access="field.camelcase" />

    <property name="Code" unique="true" />
    <property name="Provider" />
    <property name="CustomerName" />
    <property name="OrderTime" />

    <property name="DeclarationCode" />
    <property name="DeclarationCurrency" />
    <property name="DeclarationAmount" />
    <property name="AccountExchangeRate" />
    <property name="TradeAmount" />
    <property name="ExportDate" />
    <property name="Status" />
    <property name="ReportDate" />
    
    <set name="Items" cascade="all" inverse="true">
      <key column="OrderId" foreign-key="FK_Order_OrderItem" />
      <one-to-many class="KuaJing.Orders.Domain.OrderItem,KuaJing.Orders" />
    </set>
    <set name="Declarations" table="Orders_Order_Declaration" cascade="all">
      <key column="OrderId" foreign-key="FK_Order_OrderItem" />
      <many-to-many class="KuaJing.Customs.Domain.Declaration,KuaJing.Customs" column="DeclarationId" />
    </set>
    <many-to-one name="Customer" column="CustomerId" foreign-key="FK_Order_Customer" />
    <many-to-one name="ExportContract" column="ExportContractId" foreign-key="FK_Order_ExportContract" />
  
    <property name="CreatedTime" access="field.camelcase" />
    <property name="CreatedUserName" access="field.camelcase" />
    <property name="ModifiedTime" access="field.camelcase" />
    <property name="ModifiedUserName" access="field.camelcase" />
    <property name="AccessedTime" access="field.camelcase" />
    <property name="AccessedUserName" access="field.camelcase" />
    <property name="Memo" />
    <property name="IsInvalid" />
  </class>
</hibernate-mapping>
